//
//@File    :	14.21_tempparm.cpp
//@Time    :	2022/02/24 11:18:34
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	template as parameters
//

#include <iostream>
#include "14.13_stacktp.h"

//template<typename T>class是类型->即模板类,Thing是参数
template <template<typename T>class Thing>
class Crab
{
private:
    Thing<int> s1;
    Thing<double> s2;
public:
    Crab(){}
    //assumes the thing class as push() and pop() members
    bool push(int a,double x){return s1.push(a) && s2.push(x);}
    bool pop(int &a,double &x){return s1.pop(a) &&s2.pop(x);}
};



int main()
{
    using std::cout;
    using std::cin;
    using std::endl;
    Crab<Stack> nebula;
//Stack must match template<typename T> class thing
//Thing<int> Thing<double>分别被为实例化Stack<int> Stack<double>
    int ni;
    double nb;
    cout<<"ENter int double pairs,such as 4 3.(0 0 to end):\n";
    while (cin>>ni>>nb&&ni>0&&nb>0)
    {
        if (!nebula.push(ni,nb))
        {
            break;
        }
    }
    while (nebula.pop(ni,nb))
    {
        cout<<ni<<", "<<nb<<endl;
    }
    cout<<"Done.\n";
    system("pause");
    return 0;
}